updating oE diff

diff

include datetime.e --(default namespace is datetime) 
public function diff(datetime dt1, datetime dt2) 

Computes the difference, in seconds, between two dates.

Parameters:
  1. dt1 : the end datetime
  2. dt2 : the start datetime
Returns:

An atom, the number of seconds elapsed from dt2 to dt1.

Comments:

dt2 is subtracted from dt1, therefore, you can come up with a negative value.

Example 1:
include std/os.e -- for sleep() 
include std/datetime.e 
 
datetime d1 = now() 
? d1 
 
sleep(15)  -- sleep for 15 seconds 
 
datetime d2 = now() 
? d2 
 
integer i = diff(d1, d2)  
printf(1,"Difference is %d seconds",i) 
 
Results:

{2019,9,8,3,18,41} (your numbers will vary)
{2019,9,8,3,18,56}
Difference is 15 seconds

See Also:

add, subtract

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu